package org.huntaway.kindergarten.manager;

import org.hibernate.Criteria;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Order;
import org.huntaway.kernel.NutException;
import org.huntaway.kindergarten.po.Person;
import org.huntaway.kindergarten.util.EnumUse;
import org.huntaway.kindergarten.util.PageResult;

public class PersonMng extends BaseMng<Person> {
	public void save(Person item) {
		item.setIsuse(EnumUse.NO.getValue());
		//updateEntityUse(item);
		super.save(item);
	}
	public void delete(Person item) throws NutException {
		if(item.getIsuse().intValue()==EnumUse.YES.getValue()){
			throwException(item);
		}
		super.delete(item);
	}
	public PageResult query(PageResult pageResult,Person item) {
		Criteria cri = dateManage.createCriteria(Person.class);
		if (item.getTName() != null && !item.equals("")) {
			cri.add(Expression.like("TName", item.getTName()));
		}
		cri.addOrder(Order.asc("id"));
		return super.getRes(pageResult,cri);
	}
}
